#include<iostream>
#define N 40
using namespace std;
template <class T>
class Fvector
{
public:
    Fvector(int length)
    {
        if(length<=N)
        {
            len=length;
            for(int i=0; i<len; i++)
                arr[i]=i+1;
        }
        else
        {
            len=0;
            cout<<"no enough space!"<<endl;
        }
    }
    void append(T element)
    {
        if(len<N)
        {
            arr[len]=element;
            len++;
        }
        else
            cout<<"no enough space!"<<endl;
    }

    void print()
    {
        cout<<'[';
        for(int i=0; i<len; i++)
            cout<<arr[i]<<",";
        cout<<"\b"; //后退一格，消除最后一个逗号
        cout<<']';
    }
private:
    int len ;
    T arr[N];
};

int main()
{
    Fvector<int> obj1(3);
    obj1.append(9);
    obj1.append(45);
    obj1.print();
    return 0;
}
